package com.smartstate.ems.timedtask;

import cn.hutool.core.date.DateTime;
import com.smartstate.ems.entity.PowerEquipmentEntity;
import com.smartstate.ems.mapper.EquipmentMapper;
import com.smartstate.ems.mapper.EquipmentPowerMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Service
public class MonthlySummaryService {

    @Autowired
    private EquipmentMapper equipmentMapper;

    @Autowired
    private EquipmentPowerMapper equipmentPowerMapper;

    public List<PowerEquipmentEntity> statisticsOnceAMonth(DateTime startDate, DateTime endDate) {
        List<Map<String, Object>> strings = equipmentMapper.queryDeviceId("电表");
        List<PowerEquipmentEntity> power = new ArrayList<>();
        for (Map<String, Object> string : strings) {
            System.out.println("string = " + string);
            power = equipmentPowerMapper.getPower(startDate, endDate, String.valueOf(string.get("id")));
        }

        return power;
    }
}
